<template>
    <view class="content">
        <view class="title">
            <view>基本资料</view>
        </view>
        <view class="box">
            <view class="item">
                <view class="item-l">姓名</view>
                <view class="item-r">{{data.name}}</view>
            </view>
            <view class="item">
                <view class="item-l">性别</view>
                <view class="item-r">{{ data.gender == 1 ? '男' : '女' }}</view>
            </view>
            <view class="item">
                <view class="item-l">年龄</view>
                <view class="item-r">{{data.age}}岁</view>
            </view>
            <view class="item">
                <view class="item-l">性格</view>
                <view class="item-r">{{data.character}}</view>
            </view>
            <view class="item">
                <view class="item-l">爱好</view>
                <view class="item-r">{{data.hobby}}</view>
            </view>
            <view class="item">
                <view class="item-l">疾病史</view>
                <view class="item-r">{{data.disease}}</view>
            </view>
        </view>
        
        <view class="title">
            <view>过敏源</view>
        </view>
        <view class="box">
            <view class="item-r">{{data.allergy}}</view>
        </view>
        
        <view class="title">
            <view>学习记录</view>
            <view class="more" @click="$gTo(`/pages/order/study-record?id=${id}`)">查看更多</view>
        </view>
        <view class="list" v-for="(item, index) in data.record" :key="index"
             @click="$gTo(`/mine/pages/child-info/child-record-details?id=${item.id}`)">
            <image :src="item.image" class="img"></image>
            <view>
                <view class="name">{{item.name}}</view>
                <view class="btns">
                    <view class="btn">查看详情</view>
                </view>
            </view>
        </view>
        
        <view style="text-align: center;padding: 50upx 0;color: #999;font-size: 24rpx;" v-if="data.record.length == 0">暂无相关信息</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
                data: {},
            };
        },
        onLoad(option) {
            this.id = option.id
            this.getData()
        },
        methods: {
            
            getData() {
            	this.$ajax('child_detail', {
            		user_token: this.$getSync('userToken'),
                    id: this.id,//孩子资料id
            	}).then(ret => {
            		if (ret.success == 1000) {
                        this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    
    page{
        background-color: #f5f5f5;
    }
    .content{
        padding: 20rpx;
    }
    .title{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 20rpx;
        font-size: 32rpx;
        font-weight: bold;
    }
    .more{
        font-size: 26rpx;
        font-weight: normal;
    }
    .box{
        padding: 35rpx 30rpx;
        background-color: #fff;
        border-radius: 15rpx;
        margin-bottom: 35rpx;
    }
    .item{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        padding-bottom: 20rpx;
        font-size: 26rpx;
    }
    .item:last-child{
        padding-bottom: 0;
    }
    .item-l{
        width: 100rpx;
    }
    .item-r{
        flex: 1;
        white-space: pre-line;
        word-break: break-all;
        font-weight: bold;
    }
    
    .list{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 30rpx 35rpx;
        margin-bottom: 20rpx;
        background-color: #fff;
        border-radius: 15rpx;
    }
    .img{
        width: 140rpx;
        height: 140rpx;
        border-radius: 10rpx;
        margin-right: 25rpx;
    }
    .name{
        font-size: 32rpx;
        font-weight: bold;
        width: 480rpx;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-bottom: 30rpx;
    }
    .btns{
        display: flex;
        justify-content: flex-end;
        align-items: center;
    }
    .btn{
        padding: 15rpx 23rpx;
        font-size: 24rpx;
        color: #fff;
        background-color: #f29700;
        border-radius: 10rpx;
    }

</style>
